﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestGenerator
{
    class CombinationGenerator
    {
        public static int[] ChooseFrom(int chooseCount, int allCount)
        {
            if (chooseCount > allCount)
            {
                throw new Exception("Number of elements to choose is bigger than the number of all elements!");
            }

            int[] allElements = new int[allCount];

            for (int i = 0; i < allCount; i++)
            {
                allElements[i] = i;
            }


            int[] chosenElements = new int[chooseCount];

            for (int i = 0; i < chooseCount; i++)
            {
                Random random = new Random();
                int theChosenOne = random.Next(0, allCount - 1);

                chosenElements[i] = allElements[theChosenOne];

                for (int j = theChosenOne; j < allCount - 1; j++)
                {
                    allElements[j] = allElements[j + 1];
                }

                allCount--;
            }

            return chosenElements;
        }
    }
}
